﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NHibernate;

namespace ECommerce.Web.NHibernate.Sessions.Storage
{
    public class ContextItemSessionStorage : ISessionStorage
    {
        private const string SessionKey = "nhibernate.current_session";

        public ISession Session
        {
            get
            {
                return HttpContext.Current.Items[SessionKey] as ISession;
            }
            set
            {
                HttpContext.Current.Items[SessionKey] = value;
            }
        }

        public void RemoveFromStorage()
        {
            HttpContext.Current.Items.Remove(SessionKey);
        }
    }
}
